/************************************************************
 * Copyright (C), 2022-2030, dina. Co., Ltd.
 * FileName:        i_serialport.h
 * Author:          Dan Yin
 * Date:            2022-11-22
 * Description:     the class of serialport interface
 * Version:         1.0.0.0
 **********************************************************/

#ifndef I_SERIALPORT_H
#define I_SERIALPORT_H

#include <QObject>

#define ISerialport_iid "org.qt-project.Qt.Examples.ISerialport"

// define a pure virtual class
class ISerialport : public QObject
{
    Q_OBJECT
public:
    // open a serial port
    virtual int openSerialport() = 0;

    // close a serial port
    virtual void closeSerialport() = 0;

    // send an command package
    virtual int sendCommand(const QByteArray baInput, bool bQueued) = 0;

    // send an command package & receive data
    virtual int execCommand(QByteArray &baDataInOut, const int nSleep = 500) = 0;

signals:
    // Receive a payload packet from serialport
    void signalPayloadReceived(int nCmdType, QByteArray baPayload);
};

// declare interface
Q_DECLARE_INTERFACE(ISerialport, ISerialport_iid)

#endif // I_SERIALPORT_H
